package cn.edu.scau.cmi.zengGuanSheng.simpleFactoryPattern;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import cn.edu.scau.cmi.zengGuanSheng.comprehensiveExperiment.MainClient;
import javafx.event.ActionEvent;

import javafx.scene.control.MenuItem;

import javafx.scene.control.TextArea;
import javafx.scene.image.ImageView;

import javafx.scene.control.MenuButton;

public class MyController {
	@FXML
	private TextArea textArea;
	@FXML
	private Button btn;
	@FXML
	private MenuButton MenuBtn;
	@FXML
	private MenuItem menu1;
	@FXML
	private MenuItem menu2;
	@FXML
	private MenuItem menu3;
	@FXML
	private MenuItem menu4;
	@FXML
	private ImageView imageView;
	
	@FXML
	private Button btn_return;//综合性实验comprehensiveExperiment用到
	
	private static Insurance insurance= null;

	// Event Listener on Button[#btn].onAction
	@FXML
	public void eventButton(ActionEvent event) {
		// TODO Autogenerated
		textArea.clear();
		if(null==insurance)
			textArea.setText("请先选择保险类型");
		else 
			textArea.setText(insurance.claim());
	}
	// Event Listener on MenuItem[#menu1].onAction
	@FXML
	public void eventMenuItem1(ActionEvent event) {
		// TODO Autogenerated
		insurance = InsuranceFactory.getInsurance("BodyInjury");
		MenuBtn.setText("司机受伤");
	}
	// Event Listener on MenuItem[#menu2].onAction
	@FXML
	public void eventMenuItem2(ActionEvent event) {
		// TODO Autogenerated
		insurance = InsuranceFactory.getInsurance("CarDamage");
		MenuBtn.setText("汽车损坏");
		/*
		 * 设置显示不同的照片
		 */
		//绝对路径
//		imageView.setImage(new Image("file:D:\\软件体系结构\\Experiment\\201627010601曾观胜\\img\\xing.jpg"));
		//相对路径
//		imageView.setImage(new Image("file:img/xing.jpg"));
	}
	// Event Listener on MenuItem[#menu3].onAction
	@FXML
	public void eventMenuItem3(ActionEvent event) {
		// TODO Autogenerated
		insurance = InsuranceFactory.getInsurance("Casualty");
		MenuBtn.setText("人员伤亡");
	}
	// Event Listener on MenuItem[#menu4].onAction
	@FXML
	public void eventMenuItem4(ActionEvent event) {
		// TODO Autogenerated
		insurance = InsuranceFactory.getInsurance("MultipleAccidents");
		MenuBtn.setText("多种事故");
	}
	
	//综合性实验需要调用的事件处理
	@FXML
	public void eventReturn(ActionEvent event) {
		MainClient main = new MainClient();
		main.start(SimpleFactoryClientForComprehensiveExperiment.primaryStage);
	}
}
